package com.weiyi.mashangzhu.Landlord.Activity;


import android.app.FragmentManager;
import android.content.Intent;
import android.net.Uri;
import  android.support.v4.app.FragmentTransaction;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.util.Log;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.app.hubert.library.HighLight;
import com.app.hubert.library.NewbieGuide;
import com.weiyi.mashangzhu.Base.BaseActivity;
import com.weiyi.mashangzhu.Landlord.Fragment.Fragment_House_L;
import com.weiyi.mashangzhu.Landlord.Fragment.Fragment_Order_L;
import com.weiyi.mashangzhu.Landlord.Fragment.Fragment_Person_L;
import com.weiyi.mashangzhu.R;
import com.weiyi.mashangzhu.Roomer.Activity.SearchActivity;
import com.weiyi.mashangzhu.Roomer.Fragment.Fragment_Main;
import com.weiyi.mashangzhu.Roomer.Fragment.Fragment_Message;
import com.weiyi.mashangzhu.Roomer.Fragment.Fragment_Order;
import com.weiyi.mashangzhu.Roomer.Fragment.Fragment_Person;
import com.weiyi.mashangzhu.Utils.SPUtils;
import com.weiyi.mashangzhu.Utils.T;
import com.weiyi.mashangzhu.Utils.UiUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity_L extends BaseActivity {
    @BindView(R.id.rd_group)
    RadioGroup rdGroup;
    @BindView(R.id.rd_menu_house)
    RadioButton rdMenuHouse;
    @BindView(R.id.rd_menu_message)
    RadioButton rdMenuMessage;
    @BindView(R.id.rd_menu_order)
    RadioButton rdMenuOrder;
    @BindView(R.id.rd_menu_person)
    RadioButton rdMenuPerson;
    private Fragment_House_L fragment_house = new Fragment_House_L();
    private Fragment_Message fragment_message = new Fragment_Message();
    private Fragment_Order_L fragment_order = new Fragment_Order_L();
    private Fragment_Person_L fragment_person = new Fragment_Person_L();
    private android.support.v4.app.FragmentManager fragmentManager;

    @Override
    protected void onDestroy() {
        super.onDestroy();
        SPUtils.put(MainActivity_L.this, "loginLeve", "3");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_l);
        SPUtils.put(MainActivity_L.this, "loginLeve", "2");
        ButterKnife.bind(this);
        // 设置默认的Fragment
        initView();
        NewbieGuide.with(this)//传入activity
                .setLabel("guide1")//设置引导层标示，用于区分不同引导层，必传！否则报错
                .addHighLight(rdMenuHouse, HighLight.Type.RECTANGLE)//添加需要高亮的view
                .setEveryWhereCancelable(false)//设置点击任何区域消失，默认为true
                .setLayoutRes(R.layout.view_guide,R.id.iv)//自定义的提示layout，不要添加背景色，引导层背景色通过setBackgroundColor()设置
                .show();//显示引导层

    }
    @Override
    public void permissionSuccess(int requestCode) {
        super.permissionSuccess(requestCode);
        switch (requestCode){
            case 0x004:
                Log.e("hhhhhhhhhhhhhhhhh","16");
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_CALL);
                intent.setData(Uri.parse("tel:" +  "4000000000"));
                startActivity(intent);
                break;
        }

    }

    @Override
    public void initView() {
        //radiogroup默认选中的选项
        rdMenuOrder.setChecked(true);
        //默认显示的fragment
        fragmentManager = getSupportFragmentManager();
        android.support.v4.app.FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.replace(R.id.fragment_container, fragment_order);
        transaction.commit();
        //radiobutton的点击事件
        rdGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                switch (checkedId) {
                    case R.id.rd_menu_house:
                        android.support.v4.app.FragmentTransaction transaction_main = fragmentManager.beginTransaction();
                        transaction_main.replace(R.id.fragment_container, fragment_house);
                        transaction_main.commit();

                        break;
                    case R.id.rd_menu_message:
                        FragmentTransaction transaction_message = fragmentManager.beginTransaction();
                        transaction_message.replace(R.id.fragment_container, fragment_message);
                        transaction_message.commit();
                        break;
                    case R.id.rd_menu_order:
                        FragmentTransaction transaction_order = fragmentManager.beginTransaction();
                        transaction_order.replace(R.id.fragment_container, fragment_order);
                        transaction_order.commit();
                        break;
                    case R.id.rd_menu_person:
                        FragmentTransaction transaction_person = fragmentManager.beginTransaction();
                        transaction_person.replace(R.id.fragment_container, fragment_person);
                        transaction_person.commit();
                        break;
                }
            }
        });


        super.initView();
    }


}
